import { useEffect } from "react";
import { useDispatch } from "react-redux";
import { resetComponents } from "@/store/componentReducer";

const initData = {
  componentList: [
    {
      id: "1",
      type: "QTitle",
      props: {
        text: "问卷标题",
        level: 1,
      },
    },
    {
      id: "2",
      type: "QInput",
      props: {
        placeholder: "请输入内容",
        title: "输入框标题",
      },
    },
  ],
};
function useLoadQuestionData() {
  const dispatch = useDispatch();

  useEffect(() => {
    // 初始化store中的组件列表
    dispatch(resetComponents(initData));
  });
}

export default useLoadQuestionData;
